1 package org.smartcomps.twister.engine.core.definition; 2 3 import junit.framework.TestCase; 4 import net.sf.hibernate.tool.hbm2ddl.SchemaExport; 5 import net.sf.hibernate.cfg.Configuration; 6 import org.smartcomps.twister.common.transaction.TransactionManager; 7 import org.smartcomps.twister.common.lifecycle.LifecycleManager; 8 import org.smartcomps.twister.util.BeanTester; 9 import org.smartcomps.twister.engine.priv.core.definition.ActivityFactory; 10 import org.smartcomps.twister.engine.priv.core.definition.Receive; 11 import org.smartcomps.twister.engine.priv.core.definition.ProcessFactory; 12 import org.smartcomps.twister.engine.priv.core.definition.CorrelationRef; 13 14 public class TestReceive extends TestCase { 15 16 public static Receive receive = null; 17 18 public static String REC_OPERATION = "operation"; 19 public static String REC_PARTNER = "partner"; 20 public static String REC_PORT = "portType"; 21 public static String REC_VAR = "variable"; 22 23 private BeanTester beanTester = new BeanTester(new String[] {"Id", "Index"}); 24 private TestProcess testProcess = new TestProcess(); 25 26 protected void setUp() throws Exception { 27 LifecycleManager.getLifecycleManager().createResources(); 28 LifecycleManager.getLifecycleManager().startResources(); 29 30 SchemaExport schemaExport = new SchemaExport(new Configuration().configure()); 31 schemaExport.create(true, true); 32 33 TransactionManager.beginTransaction(); 34 testProcess.testCreate(); 35 } 36 37 protected void tearDown() throws Exception { 38 TransactionManager.commitTransaction(); 39 40 LifecycleManager.getLifecycleManager().stopResources(); 41 LifecycleManager.getLifecycleManager().destroyResources(); 42 } 43 44 public void testCreate() throws Exception { 45 receive = (Receive) ActivityFactory.createActivity(Receive.class, TestProcess.testProcess); 46 receive.setCreateInstance(false); 47 ActivityFactory.addCorrelationRef(receive, TestProcess.CORRELATION_NAME, true, CorrelationRef.NONE); 48 beanTester.initializeProperties("testReceive", receive); 49 50 TransactionManager.commitTransaction(); 51 TransactionManager.beginTransaction(); 52 53 Receive resultReceive = (Receive) ProcessFactory.getByName(TestProcess.testProcess.getName()).getActivity(); 54 assertTrue("Receive attributes values have been changed.", beanTester.testValues("testReceive", resultReceive)); 55 assertEquals("Receive correlation set name has changed", TestProcess.CORRELATION_NAME, ((CorrelationRef)resultReceive.getCorrelations().iterator().next()).getSet()); 56 assertEquals("Receive correlation initiate has changed", true, ((CorrelationRef)resultReceive.getCorrelations().iterator().next()).isInitiate()); 57 assertEquals("Receive correlation pattern has changed", CorrelationRef.NONE, ((CorrelationRef)resultReceive.getCorrelations().iterator().next()).getPattern()); 58 receive = resultReceive; 59 } 60 61 public void testCreateWithValues() throws Exception { 62 receive = (Receive) ActivityFactory.createActivity(Receive.class, TestProcess.testProcess); 63 receive.setCreateInstance(false); 64 ActivityFactory.addCorrelationRef(receive, TestProcess.CORRELATION_NAME, false, CorrelationRef.NONE); 65 receive.setOperation(REC_OPERATION); 66 receive.setPartner(REC_PARTNER); 67 receive.setPortType(REC_PORT); 68 receive.setVariable(REC_VAR); 69 70 TransactionManager.commitTransaction(); 71 TransactionManager.beginTransaction(); 72 73 Receive resultReceive = (Receive) ProcessFactory.getByName(TestProcess.testProcess.getName()).getActivity(); 74 assertNotNull("A null receive has been found", resultReceive); 75 receive = resultReceive; 76 } 77 78 }

This page was automatically generated by Maven